package operator;

import book.Book;
import book.BookList;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-18
 */
public interface IOperation {
    void work(BookList bookList);//可作为所有操作接口
    //寻找目标书籍的下标
    default public int findIndex(BookList bookList, String name) {
        int size = bookList.getSize();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getPos(i);
            if (name.equals(book.getName())) {
                return i;
            }
        }

        return -1;
    }
}
